package ira.src;

public class BankAccount {
	
	private double annualGain;
	private double balance;
	private double contributionAmount;
	private double rate;
	private int contributionPeriods;
	
	BankAccount(){
		annualGain = 0;
		balance = 0;
		contributionAmount = 0;
		contributionPeriods = 0;
	}
	void addPrincipal(float principal){
		balance = principal;
	}
	double addInterest(double interest) {
		rate = interest;
		annualGain = rate * balance;
		balance += annualGain;
		return balance;
	}
	double compoundInterest(double balance){
		double compoundGain = balance * addInterest(rate);
		return compoundGain;
	}
	void addContribution(int num, double contribution){
		contributionPeriods = num;
		contributionAmount = contribution;
		for (int i = 1; i < contributionPeriods; i++) {
			balance += contributionAmount;
			compoundInterest(balance);
		}
	}
	double printBalance(){
		return balance;
	}
}
